package com.wetao.lib_common.monitor;

import android.content.Context;

import java.util.HashMap;

public class TimeMonitorManager {

    private static TimeMonitorManager mTimeMonitorManager = null;
    private static Context mContext = null;
    private HashMap<Integer, TimeMonitor> timeMonitorList = null;

    public synchronized static TimeMonitorManager getInstance() {
        if (mTimeMonitorManager == null) {
            mTimeMonitorManager = new TimeMonitorManager();
        }
        return mTimeMonitorManager;
    }

    private TimeMonitorManager() {
        timeMonitorList = new HashMap<>();
    }

    // 初始化打点器
    public void resetTimeMonitor(int id) {
        TimeMonitor monitor = timeMonitorList.get(id);
        if (monitor != null) {
            timeMonitorList.remove(id);
        }
        getTimeMonitor(id);
    }

    public TimeMonitor getTimeMonitor(int id) {
        TimeMonitor monitor = timeMonitorList.get(id);
        if (monitor == null) {
            monitor = new TimeMonitor(id);
            monitor.startMonitor();
            timeMonitorList.put(id, monitor);
        }
        return monitor;
    }

}

